<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/headMain.jsp" %>
<html>
  <head>
    <title>用户管理</title>
  </head>
  		<script type="text/javascript">
		$(function(){
				jQuery("#_moduleGrid").jqGrid({
				   	url: "${base}/module_getList",
					datatype: "json",
				   	colNames:['ID','模块名称','模块地址','状态','删除'],
				   	colModel:[
				   		{name:'id',index:'id', width:55, align:'center',hidden:true},
				   		{name:'modulename', index:'modulename', align:'center'},
				   		{name:'action', index:'action', align:'center'},
				   		{name:'status', index:'status', align:'center'},
				   		{name:'edit', index:'edit', align:'center'},
				   	],
				   	width:_width_,
				   	height:230,
				   	rowNum:10,
				   	rowList:[10,20,30],
				   	pager: '#_moduleBar',
				   	sortname: 'id',
				    viewrecords: true,
				    sortorder: "desc",
					multiselect: false,
					jsonReader: {
						repeatitems : false
					},
					rownumbers : true,
					caption: "模块管理",
					afterInsertRow : function(rowid, data) {
						if(data.status == "0"){
							$("#_moduleGrid").jqGrid('setCell', rowid, 'status', '<span style="cursor:pointer;" onclick="_modifyStatus(' + data.id + ',1);">无效</span>', {color : 'purple'});
						}else{
							$("#_moduleGrid").jqGrid('setCell', rowid, 'status', '<span style="cursor:pointer;" onclick="_modifyStatus(' + data.id + ',0);">有效</span>', {color : 'purple'});
						}
						
						$("#_moduleGrid").jqGrid('setCell', rowid, 'edit', '<span style="cursor:pointer;" onclick="_updateModule('+data.id+',\''+data.modulename+'\',\''+data.action+'\');">修改</span>|&nbsp;<span style="cursor:pointer;" onclick="_delModule(' + data.id + ');">删除</span>', {color:'green'});
					}
				});
				jQuery("#_moduleGrid").jqGrid('navGrid','#_moduleBar',{add : false, del : false, edit : false, refresh : true, search : false});
				jQuery.div.util.dialogInit("增加/编辑模块信息", "_addOrUpdateModule", 500,200);
		});
		// 增加或修改模块（资源）
		function _addOrUpdateModule(){
			//window.location.href="${base}/module_addOrUpdateModule";
			//$("#_addOrUpdateModule").dialog("open");
			$('#_addOrUpdateModule').dialog('open').load('${base}/module_addOrUpdateModule', function(){
				jQuery.div.util.hideLoading();
			});
		}
		function _updateModule(id,modulename,action){
			$('#_addOrUpdateModule').dialog('open').load('${base}/module_addOrUpdateModule', function(){
				$("#_update_id").val(id);
				$("#_update_modulename").val(modulename);
				$("#_update_action").val(action);
				jQuery.div.util.hideLoading();
			});
		}
		//删除模块（资源）
		function _delModule(id) {
			if (confirm("删除模块吗？")){
				$.post("${base}/module_deleteModule/" + id, 
					function(data) {
						if (data && data.success) {
							alert(data.msg);
							$("#_moduleGrid").jqGrid('setGridParam',{url: '${base}/module_getList'}).trigger("reloadGrid");
						} else {
							alert(data.msg);
						}
					}, 
				"json");
			}
		}
		function _modifyStatus(moduleId,status){
			if (confirm("修改模块状态么？")){
				$.post("${base}/module_modifyStatus" , 
					"moduleId="+moduleId+"&status="+status,
					function(data) {
						alert(data.msg);
						$("#_moduleGrid").trigger("reloadGrid");
					}, 
				"json");
			}
		}
		</script>
	<body>
	<table cellpadding="0" cellspacing="0" border="0" width="99%" style="height:100%;">
		<tr><td style="height:10px; overflow:hidden;" colspan="2"><br></td></tr>
		<tr>
			<!--右边内容-->
			<td width="*" valign="top" class="contList">
				<!-- begin -->
					<div id="_moduleManagerDiv">
							<div class="mainInfo">
								<div class="subScroll" id="subScroll"><!-- 滚动条 -->
									<div class="searchList">
										<ul>
											<li><span>XXX：</span>
												<input type="text" id="" name="" />
											</li>
											<li><span>XX：</span>
												<input type="text" id="" name="" /
											</li>
										</ul>
										<div class="clearfloat"></div>
										<div class="btn">
											<strong><em class="searchIcon"></em><input type="button" value="查询" class="btn" id="" /></strong>
											<strong><em class="clearIcon"></em><input type="button" value="清空查询" class="btn"  onclick="" /></strong>
										</div>
										<div class="searchListBg"></div>
									</div>
									<div class="mainTable">
										<table id="_moduleGrid"></table><!-- 显示列表内容 -->
										<div id="_moduleBar"></div>
										<div class="contBtn btn">
											<strong><em class="addIcon"></em><input type="button" value="增加模块" class="btn" onclick="_addOrUpdateModule();"/></strong>
										</div>
											<div class="minwidth_div"></div>
										</div>
									</div>
								</div>
							</div>
					</div>
				<!-- end  -->
			</td>
	</table>
	</body>
</html>
<!-- 弹出增加模块 DIALOG -->
<div id="_addOrUpdateModule"></div>
